package com.org.javabody.vector;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

/**
 * Created by Administrator on 2017-02-07.
 */
public class VectorDemo {

    public Vector<HashMap<String,String>> getVector() {
        Vector<HashMap<String,String>> vec = new Vector<HashMap<String,String>>();
        for(int i=0; i < 10; i++) {
            HashMap<String,String> hs = new HashMap<String,String>();
            if(i==7) {//等于7时直接退出循环
                break;
            }
            hs.put(i+"",i+"A");
            vec.add(hs);//这个有返回值的方法（boolean）
        }
        return vec;
    }

    public static Vector addVector(){
        Vector vector = new Vector();
        for(int i = 0; i < 10; i++) {
            if( i== 5) {//跳过舞
                continue;
            }
            vector.addElement(i+"A");//无返回值的方法
        }
        return  vector;
    }

    public static void main(String[] args) {
        Vector vec = null;
        vec = new VectorDemo().getVector();
        Iterator it = vec.iterator();
        while(it.hasNext()) {
              System.out.println(it.next());
        }

        if(vec!=null) {
            vec = null;
        }
        vec = addVector();
        Iterator its = vec.iterator();
        while(its.hasNext()) {
            System.out.print(its.next()+" ");
        }


    }
}
